<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button>Send request</button>

  <script src="https://cdn.jsdelivr.net/npm/axios@1.6.7/dist/axios.min.js"></script>
  <script>
    function sendRequest() {
      axios({
        url: 'http://127.0.0.1/api/get',
        method: 'GET'
      })
        .then(res => {
          console.log(res.status)
          console.log(res.data)
        })
        .catch(err => {
          console.log(err)
        })
    }

    document.querySelector('button').addEventListener('click', sendRequest)
  </script>
</body>

</html>